package com.ruoyi.web.controller.system;

import java.util.List;
import java.util.concurrent.locks.ReentrantLock;

import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.CourierService;
import com.ruoyi.system.service.ICourierServiceService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 快递代拿Controller
 * 
 * @author ruoyi
 * @date 2021-06-16
 */
@RestController
@RequestMapping("/system/service")
public class CourierServiceController extends BaseController
{
    @Autowired
    private ICourierServiceService courierServiceService;

    /**
     * 查询快递代拿列表
     */
//    @PreAuthorize("@ss.hasPermi('system:service:list')")
    @GetMapping("/list")
    public TableDataInfo list(CourierService courierService)
    {
        startPage();
        List<CourierService> list = courierServiceService.selectCourierServiceList(courierService);
        return getDataTable(list);
    }

    /**
     * 导出快递代拿列表
     */
//    @PreAuthorize("@ss.hasPermi('system:service:export')")
    @Log(title = "快递代拿", businessType = BusinessType.EXPORT)
        @GetMapping("/export")
    public AjaxResult export(CourierService courierService)
    {
        List<CourierService> list = courierServiceService.selectCourierServiceList(courierService);
        ExcelUtil<CourierService> util = new ExcelUtil<CourierService>(CourierService.class);
        return util.exportExcel(list, "service");
    }


    //查看详情
//    @PreAuthorize("@ss.hasPermi('system:service:query')")
    @GetMapping(value = "/{couId}")
    public AjaxResult getInfo(@PathVariable("couId") Long couId)
    {
        return AjaxResult.success(courierServiceService.detail(couId));
    }

    /**
     * 新增快递代拿
     */
//    @PreAuthorize("@ss.hasPermi('system:service:add')")
    @Log(title = "快递代拿", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CourierService courierService)
    {
        return toAjax(courierServiceService.insertCourierService(courierService));
    }

    /**
     * 修改快递代拿
     */
//    @PreAuthorize("@ss.hasPermi('system:service:edit')")
    @Log(title = "快递代拿", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CourierService courierService)
    {
        return toAjax(courierServiceService.updateCourierService(courierService));
    }

    /**
     * 删除快递代拿
     */
//    @PreAuthorize("@ss.hasPermi('system:service:remove')")
    @Log(title = "快递代拿", businessType = BusinessType.DELETE)
	@DeleteMapping("/{couIds}")
    public AjaxResult remove(@PathVariable Long[] couIds)
    {
        return toAjax(courierServiceService.deleteCourierServiceByIds(couIds));
    }


}
